package com.tianma315.admin.open;

import com.alibaba.fastjson.JSONObject;
import com.tianma315.admin.common.utils.Result;
import com.tianma315.admin.material.VO.PurchaseAndArrtVO;
import com.tianma315.admin.material.service.PurchaseService;
import com.tianma315.admin.statisticstable.service.StatisticsService;
import com.tianma315.admin.stock.domain.vo.WarehousingRecordAndArrtVO;
import com.tianma315.admin.stock.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Calendar;
import java.util.List;

@RequestMapping("/open")
@RestController
public class OpenController {
    @Autowired
    private StockService stockService;

    @Autowired
    private PurchaseService purchaseService;

    @Autowired
    private StatisticsService statisticsService;

//    @GetMapping("/statisticsTable")
//    Result<JSONObject> statisticsTable() {
////        List<WarehousingRecordAndArrtVO> list = stockService.statisticsTable(1);
//        JSONObject jsonObject = statisticsService.statisticsProductTable(1);
//        return Result.ok(jsonObject);
//    }
//    @GetMapping("/statisticsProductTable")
//    Result<List<WarehousingRecordAndArrtVO>> statisticsProductTable() {
//        List<WarehousingRecordAndArrtVO> list = stockService.statisticsTable(1);
//        return Result.ok(list);
//    }


    @GetMapping("/purchase")
    Result<List<PurchaseAndArrtVO>> purchase() {
        Calendar cal=Calendar.getInstance();
        cal.add(Calendar.DATE,-3);
        Calendar cal2=Calendar.getInstance();
        List<PurchaseAndArrtVO> list =
                purchaseService.statisticsMaterialAllTable(null,cal.getTime(),cal2.getTime());
        return Result.ok(list);
    }
}
